<style lang="less" scoped>
.panel {
  margin-bottom: 10px;
  &-title {
    display: flex;
    padding: 10px;
    border-bottom: 0.1px solid #eaeaea;
    background: white;

    &__label {
      flex: 1;
      font-size: 16px;
      align-items: center;
    }
  }
  &-content {
    margin-bottom: 10px;
    background: white;
    display: flex;

    &__dec {
      flex: 1;
    }
    &__arrow {
      display: flex;
      align-items: center;
    }
    &__item {
      display: flex;
      padding: 10px 10px 0 10px;
      font-size: 14px;
      &-label {
        color: #666;
      }
      &-value {
        flex: 1;
        padding-left: 15px;
        color: #333;
      }
    }
  }
}
</style>

<template>
    <div class="info" v-if="items.length==0">暂无数据</div>
    <div class="panel" v-else>
        <template v-for="(item, index) in items" wx:key="unique">
            <!-- content -->
            <div class="panel-content" :key="'content'+index" @click="itemClick(item)">
                <div class="panel-content__dec">
                    <div class="panel-content__item">
                        <div class="panel-content__item-label avator">
                            <image class="avator-img" v-if="item.avatar" :src="item.avatar" />
                            <text-to-avator v-else :text="item.Name"></text-to-avator>
                        </div>
                        <div class="panel-content__item-value">{{item.Name||'-'}} <br>{{item.Job||'-'}}</div>
                        <div class="panel-content__item-right">他关联{{item.CompanyCount||0}}家公司</div>
                    </div>
                </div>
                <div class="panel-content__arrow">
                    <i class="iconfont icon-more"></i>
                </div>
            </div>
        </template>
    </div>
</template>
<script>
import TextToAvator from '@/components/textToAvator';
export default {
  components: { TextToAvator },
  data() {
    return {
      items: []
    };
  },
  onLoad() {
    this.getInfos();
  },
  onUnload() {
    this.items = [];
  },
  methods: {
    changeCount(count) {
      const item = { type: 'gaoguan', count };
      this.$emit('countChange', item);
    },
    getInfos() {
      try {
        this.items = this.$store.getters.companyInfo.Company.Employees;
        this.changeCount(this.items.length || 0);
      } catch (error) {
        console.log(error);
      }
    },
    itemClick(item) {
      // KeyNo Name
      // 展示详情
      this.$router.push({
        path: '/pages/base/faren/main',
        query: { Oper: JSON.stringify(item) }
      });
    }
  }
};
</script>
